import axios from "axios";

// 创建 axios 实例
const service = axios.create({
  baseURL: "/api",
  timeout: 2000,
});

// 请求拦截器
service.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    console.log(error);
    return Promise.reject(error);
  }
);
// 响应拦截器
service.interceptors.response.use(
  (response) => {
    const res = response.data;
    return res;
  },
  (error) => {
    console.log("请求错误:", error.message);
    return Promise.reject(error);
  }
);

export default service;
